package com.itheima.controller;

import com.itheima.bean.Orders;
import com.itheima.common.R;
import com.itheima.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequestMapping("/order")
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("/submit")
    public R sumbit(@RequestBody Orders orders){
        log.info("orders:{}",orders);

        //调用service完成用户下单
        orderService.submit(orders);

        return R.success("用户下单成功！");
    }
}
